package com.yuma.lock;

class SyncTest{
    public void test(){
        // 也是可重入锁
        synchronized (this){
            System.out.println("第一次加锁");
            synchronized (this){
                System.out.println("第二次加锁");
                synchronized (this){
                    System.out.println("第三次加锁");
                }
            }
        }
    }

    public synchronized void a(){
        System.out.println("a");
        b();
    }
    public synchronized void b(){
        System.out.println("b");
    }
}

public class SyncReentrantDemo {
    public static void main(String[] args) {
        SyncTest st = new SyncTest();
        st.test();
        st.a();
    }
}